
function add0(m) { return m < 10 ? `0${m}` : m; }
/** 时间戳转换时间 */
export function getLocalTime(nS) {
    if (nS) {
        const time = new Date(parseInt(nS, 10) * 1000);
        const y = time.getFullYear();
        const m = time.getMonth() + 1;
        const d = time.getDate();
        const h = time.getHours();
        const mm = time.getMinutes();
        const s = time.getSeconds();
        return `${y}-${add0(m)}-${add0(d)} ${add0(h)}:${add0(mm)}:${add0(s)}`;
    }
    return nS;
}

/** 时间戳转换时间 */
export function getDateTime(nS) {
    if (nS) {
        const time = new Date(parseInt(nS, 10) * 1000);
        const y = time.getFullYear();
        const m = time.getMonth() + 1;
        const d = time.getDate();
        return `${y}年${add0(m)}月${add0(d)}日`;
    }
    return nS;
}

export function getMonthDay(nS) {
    if (nS) {
        const time = new Date(parseInt(nS, 10) * 1000);
        const y = time.getFullYear();
        const m = time.getMonth() + 1;
        const d = time.getDate();
        return `${add0(m)}.${add0(d)}`;
    }
    return nS;
}
export function getYearDay(nS, flag) {
    if (nS) {
        const time = new Date(parseInt(nS, 10) * 1000);
        const y = time.getFullYear();
        const m = time.getMonth() + 1;
        const d = time.getDate();
        return `${y}${flag}${add0(m)}${flag}${add0(d)}`;
    }
    return nS;
}

export function getReserveTime(nS) {
    if (nS) {
        const time = new Date(parseInt(nS, 10) * 1000);
        const h = time.getHours();
        const mm = time.getMinutes();
        return `${add0(h)}:${add0(mm)}`;
    }
    return nS;
}
